﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Navigation;

namespace ConstellationShow
{
    public partial class MainPage : MyPage
    {
        static bool isAppLoad = false;
        // 构造函数
        public MainPage()
        {
            InitializeComponent();
            
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (!isAppLoad)
            {
                object o = Com.GetSetting("skip");
                object oo = Com.GetSetting("cons");
                if (o != null && oo != null && (oo as List<Cons>).Count > 0)
                    NavigationService.Navigate(new Uri("/Pages/Core.xaml?id=" + (oo as List<Cons>)[0].id, UriKind.Relative));
                isAppLoad = true;
            }

            //清空历史记录防止Back键回退
            JournalEntry entry = NavigationService.RemoveBackEntry();
            while (entry != null)
                entry = NavigationService.RemoveBackEntry();
            base.OnNavigatedTo(e);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            NavigationService.Navigate(new Uri("/Pages/Core.xaml?id=" + btn.CommandParameter.ToString(), UriKind.Relative));
        }

        private void ApplicationBarIconButton_Click_Search(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/Pages/Select.xaml", UriKind.Relative));
        }

        private void ApplicationBarIconButton_Click_Setting(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/Pages/Setting.xaml", UriKind.Relative));
        }

    }
}